home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus Leser 19 / Amiga Plus Leser CD 19.iso / Tools / Freeware / Swf_Player / Lib / program.h < prev    next >
Encoding:
C/C++ Source or Header  |  2002-11-17  |  4.9 KB  |  188 lines

  1. /////////////////////////////////////////////////////////////
  2. // Flash Plugin and Player
  3. // Copyright (C) 1998 Olivier Debon
  4. // 
  5. // This program is free software; you can redistribute it and/or
  6. // modify it under the terms of the GNU General Public License
  7. // as published by the Free Software Foundation; either version 2
  8. // of the License, or (at your option) any later version.
  9. // 
  10. // This program is distributed in the hope that it will be useful,
  11. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13. // GNU General Public License for more details.
  14. // 
  15. // You should have received a copy of the GNU General Public License
  16. // along with this program; if not, write to the Free Software
  17. // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
  18. // 
  19. ///////////////////////////////////////////////////////////////
  20. #ifndef _PROGRAM_H_
  21. #define _PROGRAM_H_
  22.  
  23. #include "amiga_specific.h"
  24.  
  25. enum ControlType {
  26.     ctrlPlaceObject,
  27.     ctrlPlaceObject2,
  28.     ctrlRemoveObject,
  29.     ctrlRemoveObject2,
  30.     ctrlDoAction,
  31.     ctrlStartSound,
  32.     ctrlStopSound,
  33.     ctrlBackgroundColor
  34. };
  35.  
  36. enum PlaceFlags {
  37.     placeIsMove        = 0x01,
  38.     placeHasCharacter    = 0x02,
  39.     placeHasMatrix        = 0x04,
  40.     placeHasColorXform    = 0x08,
  41.     placeHasRatio        = 0x10,
  42.     placeHasName        = 0x20,
  43.     placeHasClip        = 0x40
  44. };
  45.  
  46. struct Control {
  47.     ControlType    type;
  48.  
  49.     // Place, Remove, Sound
  50.     Character    *character;
  51.     long         depth;
  52.  
  53.     // Place 1&2
  54.     PlaceFlags     flags;
  55.     Matrix         matrix;
  56.     Cxform         cxform;
  57.     long         ratio;
  58.     long         clipDepth;
  59.     char        *name;
  60.  
  61.     // BackgroundColor
  62.     Color         color;
  63.  
  64.     // DoAction
  65.     ActionRecord    *actionRecords;
  66.  
  67.     struct Control *next;
  68.  
  69.  
  70.     // Methods
  71.  
  72.     void addActionRecord( ActionRecord   *ar)
  73.     {
  74.         ar->next = 0;
  75.  
  76.         if (actionRecords == 0) {
  77.             actionRecords = ar;
  78.         } else {
  79.             ActionRecord *current;
  80.  
  81.             for(current = actionRecords; current->next; current = current->next);
  82.  
  83.             current->next = ar;
  84.         }
  85.     };
  86.  
  87.     Control()
  88.     {
  89.         actionRecords = 0;
  90.         cxform.aa = 1.0; cxform.ab = 0;
  91.         cxform.ra = 1.0; cxform.rb = 0;
  92.         cxform.ga = 1.0; cxform.gb = 0;
  93.         cxform.ba = 1.0; cxform.bb = 0;
  94.         ratio = 0;
  95.         clipDepth = 0;
  96.         name = 0;
  97.     };
  98.  
  99.     ~Control()
  100.     {
  101.         ActionRecord    *ar,*del;
  102.         for(ar = actionRecords; ar;)
  103.         {
  104.             del = ar;
  105.             ar = ar->next;
  106.             delete del;
  107.         }
  108.         if (name) {
  109.             free(name);
  110.         }
  111.     };
  112. };
  113.  
  114. struct Frame {
  115.     char *label;
  116.     Control *controls;    // Controls for this frame
  117. };
  118.  
  119. enum MovieStatus {
  120.     MoviePaused,
  121.     MoviePlay
  122. };
  123.  
  124. struct FlashMovie;
  125.  
  126. struct Program {
  127.         DisplayList    *dl;
  128.  
  129.     Frame        *frames;    // Array
  130.     long         nbFrames;    // Number of valid frames
  131.     long           currentFrame;
  132.     long           loadingFrame;
  133.     long           totalFrames;    // Total expected number of frames
  134.     long           nextFrame;
  135.     int         movieWait;    // If true freeze movie until next loaded frame
  136.     MovieStatus      movieStatus;
  137.     Sound        *currentSound;
  138.     long         settings;
  139.         FlashMovie      *movie;
  140.     long         render;    // True if needed to be rendered
  141.  
  142.     Program(FlashMovie *movie,long n);
  143.     ~Program();
  144.  
  145.     void     rewindMovie();
  146.     void     pauseMovie();
  147.     void     continueMovie();
  148.     void     nextStepMovie();
  149.     void     gotoFrame(GraphicDevice *gd, long f);
  150.  
  151.     long     processMovie(GraphicDevice *, SoundMixer *);
  152.     long     nestedMovie(GraphicDevice *, SoundMixer *, Matrix *, Cxform *);
  153.     long     runFrame(GraphicDevice *, SoundMixer *, long f, long action=1);
  154.     long     handleEvent(GraphicDevice *, SoundMixer *, FlashEvent *);
  155.     long     doAction(GraphicDevice *gd, ActionRecord *action, SoundMixer *);
  156.     void     setCurrentFrameLabel(char *label);
  157.     void     advanceFrame();
  158.     void     addControlInCurrentFrame(Control *ctrl);
  159.     void     setGetUrlMethod( void (*)(char *, char *, void *), void *);
  160.     void     modifySettings(long flags);
  161.     long     searchFrame(GraphicDevice *gd, char *, char *);
  162.     void     validateLoadingFrame();
  163.     long     getCurrentFrame();
  164.     void     setCurrentFrame(long);
  165.  
  166.     Frame    *getFrames();
  167.     long     getNbFrames();
  168.  
  169.     DisplayList *getDisplayList();
  170.  
  171. #ifdef DUMP
  172.     void     dump(BitStream *bs);
  173. static  void     dumpActions(BitStream *bs, ActionRecord *actions);
  174. #endif
  175. };
  176.  
  177. DisplayListEntry *findFocus(DisplayList *dl);
  178. void setFlashTimer(struct myTimeval *tv, int time_ms);
  179. int checkFlashTimer(struct myTimeval *tv);
  180.  
  181. void loadNewSwf(FlashMovie *movie, char *url, int level);
  182.  
  183. void computeBBox(FlashMovie *movie, Rect *rect, DisplayListEntry *e);
  184.  
  185. long processMovie(FlashMovie *movie);
  186.  
  187. #endif /* _PROGRAM_H_ */
  188.